#include<iostream>
#include<algorithm>

using namespace std;


int p1, p2, p3,n;
string s;
string ret;

bool isdig(char ch)
{
	return ch >= '0' && ch <= '9';
}

//judge whether it is a lowercase letter
bool islet(char ch)
{
	return ch > 'a' && ch < 'z';
}

//expand the content
void Add(char left,char right)
{
	string s1;
	//traverse the middle characters
	for (char i = left + 1; i < right; i++)
	{
		char temp = i;
		if (p1 == 2 && islet(s[i])) temp -= 32;
		else if (p1 == 3)  temp = '*';


		for (int u = 0; u < p2; u++)
		{
			s1 += temp;
		}
	}

	if (p3 == 2)
	{
		reverse(s1.begin(), s1.end());
		
	}
	ret += s1;
}

int main()
{
	cin >> p1 >> p2 >> p3 >> s;
	n = s.size();
	 
	for (int i = 0; i < n; i++)
	{
		char ch = s[i];
		if (s[i] != '-' || i == 0 || i == n - 1) {
			ret += ch;
		}// in  minus sign
		else {
			char left = s[i - 1], right = s[i + 1];
			if (isdig(left) && isdig(right) && right > left || islet(left) && islet(right) && right > left)
			{
				Add(left, right);
			}
			else {
				ret += ch;
			}
		}

}
	cout << ret << endl;
	return 0;
}